package com.uniriho.lxr0811_7300_bl.ui.activity

import android.annotation.SuppressLint
import android.bluetooth.BluetoothDevice
import android.bluetooth.BluetoothGatt
import android.bluetooth.BluetoothGattCallback
import android.bluetooth.BluetoothGattCharacteristic
import android.bluetooth.BluetoothGattDescriptor
import android.bluetooth.BluetoothGattService
import android.content.Context
import android.content.Intent
import android.util.Log
import android.view.View
import androidx.lifecycle.ViewModel
import androidx.recyclerview.widget.LinearLayoutManager
import com.uniriho.lxr0811_7300_bl.adapter.BleDevAdapter
import com.uniriho.lxr0811_7300_bl.base.BaseApplication
import com.uniriho.lxr0811_7300_bl.base.Constant
import com.uniriho.lxr0811_7300_bl.ble.BleCon
import com.uniriho.lxr0811_7300_bl.databinding.ActivityMainBinding
import com.uniriho.lxr0811_7300_bl.utils.DataTo
import java.util.UUID

@SuppressLint("MissingPermission", "StaticFieldLeak")
class MainViewModel(mainBinding: ActivityMainBinding, context: Context) : ViewModel(),
    BleDevAdapter.Listener {
    private var mMainBinding: ActivityMainBinding
    private val TAG: String = "MainViewModel"
    private var mContext: Context
    private lateinit var device: BluetoothDevice
    private val mBleDevAdapter by lazy {
        BleDevAdapter(this, context)
    }


    init {
        mMainBinding = mainBinding
        mContext = context
        mMainBinding.rvBle.layoutManager = LinearLayoutManager(context)
        mMainBinding.rvBle.adapter = mBleDevAdapter
    }

    override fun onItemClick(dev: BluetoothDevice?) {
        BleCon.DevConnect(mContext,dev)

    }

    fun reScanBleDev(){
        mBleDevAdapter.reScan()
    }



}